/*

 Source Server         : test
 Source Server Type    : MySQL
 Source Server Version : 80022
 Source Host           : localhost:3306
 Source Schema         : food

 Target Server Type    : MySQL
 Target Server Version : 80022
 File Encoding         : 65001

 Date: 08/07/2023 12:16:59
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for dish
-- ----------------------------
DROP TABLE IF EXISTS `dish`;
CREATE TABLE `dish` (
  `dishId` int NOT NULL COMMENT '菜品ID',
  `dishName` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '菜品名称',
  `disPrice` decimal(10,2) DEFAULT NULL COMMENT '菜品价格',
  `categoryId` int NOT NULL COMMENT '菜品类别（外键）',
  `cooking` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '做法描述',
  `material` text COLLATE utf8mb4_general_ci COMMENT '主要材料',
  `description` text COLLATE utf8mb4_general_ci COMMENT '菜品描述',
  `imagesRoute` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '图片路径',
  PRIMARY KEY (`dishId`),
  KEY `categoryId_fk` (`categoryId`),
  CONSTRAINT `categoryId_fk` FOREIGN KEY (`categoryId`) REFERENCES `dishCategory` (`categoryId`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Records of dish
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for dishCategory
-- ----------------------------
DROP TABLE IF EXISTS `dishCategory`;
CREATE TABLE `dishCategory` (
  `categoryId` int NOT NULL COMMENT '菜品分类ID',
  `categoryName` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '类别名称',
  PRIMARY KEY (`categoryId`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Records of dishCategory
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for manager
-- ----------------------------
DROP TABLE IF EXISTS `manager`;
CREATE TABLE `manager` (
  `username` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户名',
  `password` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '密码',
  PRIMARY KEY (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Records of manager
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for order
-- ----------------------------
DROP TABLE IF EXISTS `order`;
CREATE TABLE `order` (
  `orderId` int NOT NULL COMMENT '订单ID',
  `username` varchar(30) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '下单用户名',
  `createTime` datetime DEFAULT NULL COMMENT '下单生成时间',
  `deliverCity` varchar(30) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '送货城市',
  `deliverAddress` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '送货地址',
  `name` varchar(30) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '收货人姓名',
  `telephone` varchar(20) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '收货人联系电话',
  `deliverTime` datetime DEFAULT NULL COMMENT '送货时间',
  `status` int DEFAULT NULL COMMENT '订单状态',
  `discount` decimal(10,2) DEFAULT NULL COMMENT '订单折扣',
  `totalPrice` decimal(10,2) DEFAULT NULL COMMENT '订单总金额',
  `deliverMan` varchar(30) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '送货员姓名',
  PRIMARY KEY (`orderId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Records of order
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for ordetDetails
-- ----------------------------
DROP TABLE IF EXISTS `ordetDetails`;
CREATE TABLE `ordetDetails` (
  `orderId` int NOT NULL COMMENT '订单ID',
  `dishId` int NOT NULL COMMENT '菜品ID',
  `dishName` varchar(30) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '菜品名称',
  `dishPrice` decimal(10,2) DEFAULT NULL COMMENT '菜品单价',
  `quantity` int DEFAULT NULL COMMENT '所定数量',
  PRIMARY KEY (`orderId`,`dishId`),
  KEY `dishId_dt_fk` (`dishId`),
  CONSTRAINT `dishId_dt_fk` FOREIGN KEY (`dishId`) REFERENCES `dish` (`dishId`),
  CONSTRAINT `orderId_dt_fk` FOREIGN KEY (`orderId`) REFERENCES `order` (`orderId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Records of ordetDetails
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
  `username` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户名',
  `password` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '密码',
  `trueName` varchar(30) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '真实姓名',
  `telephone` varchar(20) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '联系电话',
  `city` varchar(30) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '所在城市',
  `address` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '地址',
  PRIMARY KEY (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Records of user
-- ----------------------------
BEGIN;
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;
